/**
 * 
 */
package mx.netbrain.bean;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import mx.netbrain.util.ConnectionMySQL;
import mx.netbrain.util.ReadXML;

/**
 * @author julian
 * 
 */
public class DataBaseBean {

	private String dataBase;
	private String driver;
	private String host;
	private String user;
	private String password;

	public DataBaseBean() {
		ReadXML read = new ReadXML();
		driver = read.getDriver();
		host = read.getUrl();
		user = read.getUser();
		password = read.getPass();
	}

	public void test() {
		if (ConnectionMySQL.test(driver, host, user, password)) {
			FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO,
					"Conexión satisfactoria.", "");
			FacesContext.getCurrentInstance().addMessage(null, message);
		} else {
			FacesMessage message = new FacesMessage(
					FacesMessage.SEVERITY_ERROR, "Error de conexión.", "");
			FacesContext.getCurrentInstance().addMessage(null, message);
		}
	}

	public String getDataBase() {
		return dataBase;
	}

	public void setDataBase(String dataBase) {
		this.dataBase = dataBase;
	}

	public String getDriver() {
		return driver;
	}

	public void setDriver(String driver) {
		this.driver = driver;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}
